<?php

/*
|--------------------------------------------------------------------------
| API 路由定义
|--------------------------------------------------------------------------
|
| 在这里定义API路由，为了方便阅读，建议使用apiResource定义资源路由组，并对一类
| 业务路由进行分组管理！
|
*/

/**
 * 共派接口
 * /api/v1/fw/          共派后台
 * /api/v1/an/          站点后台
 * /api/v1/wd/          网点后台
 * /api/v1/client/      app接口
 */

Route::group(['prefix' => 'client'], function () {
    /**
     * 系统公用服务
     */
    Route::group(['prefix' => '/common', 'namespace' => 'Common'], function () {
        //发送验证码
        Route::post('sendCode', 'MessageController@sendCode');
        //文件上传
        Route::post('upload', 'UploadController@upload');
        //文件删除
        Route::post('destroy', 'UploadController@destroy');
    });

    /**
     * 快递员注册认证路由组
     */
    Route::group(['prefix' => '/auth', 'namespace' => 'Client'], function () {
        //登录
        Route::post('login', 'LoginController@login');
        //注销
        Route::post('logout', 'LoginController@logout')->middleware('auth:courier');
        //身份证认证
        Route::post('authentication', 'LoginController@authentication')->middleware('auth:courier');
        Route::post('upload', 'LoginController@upload');
        //共派条款
        Route::post('agreement', 'LoginController@agreement');
    });

    /**
     * 首页模块
     */
    Route::group(['prefix' => '/home', 'namespace' => 'Client', 'middleware' => 'auth:courier'], function () {
        //派件列表
        Route::post('lists', 'WorkController@lists');
        //标记
        Route::post('sign', 'WorkController@sign');
        //签收
        Route::post('signing', 'WorkController@signing');
        //订单详情
        Route::post('detail', 'WorkController@detail');
    });

    /**
     * 功能 模块
     */
    Route::group(['prefix' => '/work', 'namespace' => 'Client', 'middleware' => 'auth:courier'], function () {
        //入库
        Route::post('entry', 'WorkController@entry');
        //出库
        Route::post('delivery', 'WorkController@delivery');
        //派送
        Route::post('send', 'WorkController@send');
        //获取快递公司
        Route::post('express', 'WorkController@express');
        //获取去件码
        Route::post('code', 'WorkController@takeCode');

        //短信模板
        Route::post('template', 'MessageController@template');
    });

    /**
     * 我的 模块
     */
    Route::group(['prefix' => '/personal', 'namespace' => 'Client', 'middleware' => 'auth:courier'], function () {
        //个人资料
        Route::post('info', 'CourierController@info');
        //修改个人资料
        Route::post('update', 'CourierController@update');
        //派件订单
        Route::post('dispatch', 'WorkController@sendLists');
        //标记
        Route::post('sign', 'WorkController@sign');
        //签收
        Route::post('signing', 'WorkController@signing');
        //自提订单
        Route::post('lifting', 'WorkController@lifting');
    });
});
Route::group(['prefix' => 'fw'], function () {
    /**
     * 系统公用服务
     */
    Route::group(['prefix' => '/common', 'namespace' => 'Common'], function () {
        //发送验证码
        Route::post('sendCode', 'MessageController@sendCode');
        //文件上传
        Route::post('upload', 'UploadController@upload');
        //文件删除
        Route::post('destroy', 'UploadController@destroy');
        //省
        Route::apiResource('province', 'ProvinceController');
        //市
        Route::apiResource('city', 'CityController');
        //区、县
        Route::apiResource('district', 'DistrictController');
    });

    /**
     * 服务站登录认证路由组
     */
    Route::group(['prefix' => '/auth', 'namespace' => 'Service'], function () {
        //登录
        Route::post('login', 'LoginController@login');
        //注销
        Route::post('logout', 'LoginController@logout')->middleware('auth:station');
        //身份证认证
        Route::post('authentication', 'LoginController@authentication')->middleware('auth:station');
        Route::post('upload', 'LoginController@upload');
    });

    /**
     * 服务站首页模块
     */
    Route::group(['prefix' => '/service', 'namespace' => 'Service', 'middleware' => 'auth:station'], function () {
        //首页
        Route::post('/home/show', 'HomeController@index');
        //入库
        Route::post('/home/entry', 'HomeController@entry');
        Route::post('/home/express', 'HomeController@express');
        Route::post('/home/code', 'HomeController@takeCode');
        //自提件出库
        Route::post('/home/delivery', 'HomeController@delivery');
        Route::post('/home/delivery/data', 'HomeController@deliveryData');
        Route::post('/home/delivery/count', 'HomeController@deliveryCount');
        //退回网点
        Route::post('/home/retreat', 'HomeController@retreat');
        Route::post('/home/retreat/data', 'HomeController@retreatData');
        Route::post('/home/retreat/count', 'HomeController@retreatCount');
        //快件库
        Route::apiResource('order', 'OrderController');
        Route::post('order/services', 'OrderController@services');
        //员工管理
        Route::apiResource('courier', 'CourierController');
        Route::post('courier/existence', 'CourierController@existence');
        Route::post('courier/password', 'CourierController@password');
        //网点管理
        Route::apiResource('network', 'NetworkController');
        Route::post('network/existence', 'NetworkController@existence');
        Route::post('network/relation', 'NetworkController@relation');
        Route::post('network/edit', 'NetworkController@updateNetworkStation');
        Route::post('network/relieve', 'NetworkController@destroyRelation');
        Route::post('network/list', 'NetworkController@all');
        //快件结算
        Route::apiResource('settlement', 'SettlementController');
        //站点管理
        Route::apiResource('station', 'ServiceController');
        Route::post('station/password', 'ServiceController@password');
        Route::post('station/search', 'ServiceController@search');
        Route::post('station/relation', 'ServiceController@relationStation');
        Route::post('station/service', 'ServiceController@childStation');
        Route::post('station/existence', 'ServiceController@existence');
        Route::post('station/stop/{stop}', 'ServiceController@stop');

        //账户管理
        Route::apiResource('admin', 'AdminController');
        Route::post('admin/existence', 'AdminController@existence');
        //获取权限列表
        Route::get('permission', 'AdminController@permission');
        //获取日志
        Route::get('log', 'LogController@index');
        //快递公司
        Route::apiResource('express', 'ExpressCompanyController');
    });
});
Route::group(['prefix' => 'an'], function () {
    /**
     * 系统公用服务
     */
    Route::group(['prefix' => '/common', 'namespace' => 'Common'], function () {
        //发送验证码
        Route::post('sendCode', 'MessageController@sendCode');
        //文件上传
        Route::post('upload', 'UploadController@upload');
        //文件删除
        Route::post('destroy', 'UploadController@destroy');
        //省
        Route::apiResource('province', 'ProvinceController');
        //市
        Route::apiResource('city', 'CityController');
        //区、县
        Route::apiResource('district', 'DistrictController');
    });

    /**
     * 服务站登录认证路由组
     */
    Route::group(['prefix' => '/auth', 'namespace' => 'Admin'], function () {
        //登录
        Route::post('login', 'LoginController@login');
        //重置密码
        Route::post('password', 'LoginController@password');
        //注销
        Route::post('logout', 'LoginController@logout')->middleware('auth:admin');
    });

    /**
     * 服务站首页模块
     */
    Route::group(['prefix' => '/service', 'namespace' => 'Admin', 'middleware' => 'auth:admin'], function () {
        //会员管理
        Route::apiResource('user', 'UserController');
        Route::post('user/existence', 'UserController@existence');
        //站点管理
        Route::apiResource('station', 'ServiceController');
        Route::post('station/relation', 'ServiceController@relationStation');
        Route::post('station/relieve', 'ServiceController@destroyRelation');
        Route::post('station/service', 'ServiceController@childStation');
        Route::post('station/password', 'ServiceController@password');
        Route::post('station/search', 'ServiceController@search');
        Route::post('station/existence', 'ServiceController@existence');
        Route::get('lists', 'ServiceController@parentStation');
        //员工管理
        Route::apiResource('courier', 'CourierController');
        Route::post('courier/existence', 'CourierController@existence');
        Route::post('courier/password', 'CourierController@password');
        //网点管理
        Route::apiResource('network', 'NetworkController');
        Route::post('network/existence', 'NetworkController@existence');
        Route::post('network/station', 'NetworkController@relationStation');
        Route::post('network/edit', 'NetworkController@updateNetworkStation');
        Route::post('network/relieve', 'NetworkController@destroyRelation');
        Route::post('network/password', 'NetworkController@password');

        //快件库
        Route::apiResource('order', 'OrderController');
        //网点账单
        Route::apiResource('bill', 'NetworkBillController');

        //站点结算
        Route::get('settlement', 'ServiceBillController@index');
        Route::post('settlement/{settlement}', 'ServiceBillController@calculation');
        //账户管理
        Route::apiResource('admin', 'AdminController');
        Route::post('admin/existence', 'AdminController@existence');
        //获取权限列表
        Route::get('permission', 'AdminController@permission');
        //获取日志
        Route::get('log', 'LogController@index');
        //快递公司
        Route::apiResource('express', 'ExpressCompanyController');
    });
});
Route::group(['prefix' => 'wd'], function () {
    /**
     * 系统公用服务
     */
    Route::group(['prefix' => '/common', 'namespace' => 'Common'], function () {
        //发送验证码
        Route::post('sendCode', 'MessageController@sendCode');
        //文件上传
        Route::post('upload', 'UploadController@upload');
        //文件删除
        Route::post('destroy', 'UploadController@destroy');
        //省
        Route::apiResource('province', 'ProvinceController');
        //市
        Route::apiResource('city', 'CityController');
        //区、县
        Route::apiResource('district', 'DistrictController');
    });

    /**
     * 服务站登录认证路由组
     */
    Route::group(['prefix' => '/auth', 'namespace' => 'Network'], function () {
        //登录
        Route::post('login', 'LoginController@login');
        //注销
        Route::post('logout', 'LoginController@logout')->middleware('auth:network');
    });

    /**
     * 服务站首页模块
     */
    Route::group(['prefix' => '/network', 'namespace' => 'Network', 'middleware' => 'auth:network'], function () {
        //合作站点
        Route::post('/service', 'ServiceController@relationStation');
        //账单明细
        Route::post('/bills', 'SettlementController@index');
        Route::post('/detailed', 'SettlementController@show');
         Route::post('/charge', 'SettlementController@charge');
    });
});